﻿using System;
using UnityEngine;

namespace Sizebox.CharacterEditor
{
	// Token: 0x02000242 RID: 578
	public class CharacterEditorView : BaseView
	{
		// Token: 0x06000C5A RID: 3162 RVA: 0x00064A1C File Offset: 0x00062C1C
		protected override void OnEnable()
		{
			base.OnEnable();
			if (this.Controller.selectedEntity && this.Controller.selectedEntity != this.handleManager.TargetEditor)
			{
				CharacterEditor component = this.Controller.selectedEntity.GetComponent<CharacterEditor>();
				if (component)
				{
					this.EnableCharacterEditor();
				}
				else
				{
					this.DisableTabs();
				}
			}
		}

		// Token: 0x06000C5B RID: 3163 RVA: 0x00064A91 File Offset: 0x00062C91
		protected override void OnDisable()
		{
			base.OnDisable();
		}

		// Token: 0x06000C5C RID: 3164 RVA: 0x00064A9C File Offset: 0x00062C9C
		private void EnableTabs()
		{
			this.startView.gameObject.SetActive(false);
			foreach (ViewConfig viewConfig in this.subViews)
			{
				if (viewConfig.activator)
				{
					viewConfig.activator.interactable = true;
				}
			}
		}

		// Token: 0x06000C5D RID: 3165 RVA: 0x00064B20 File Offset: 0x00062D20
		private void DisableTabs()
		{
			base.DisableAllSubViews();
			this.startView.gameObject.SetActive(true);
			foreach (ViewConfig viewConfig in this.subViews)
			{
				if (viewConfig.activator)
				{
					viewConfig.activator.interactable = false;
				}
			}
		}

		// Token: 0x06000C5E RID: 3166 RVA: 0x00064BA8 File Offset: 0x00062DA8
		public void EnableCharacterEditor()
		{
			EntityBase selectedEntity = this.Controller.selectedEntity;
			if (!selectedEntity || selectedEntity == this.handleManager.TargetEditor)
			{
				return;
			}
			CharacterEditor characterEditor = selectedEntity.GetComponent<CharacterEditor>();
			if (!characterEditor)
			{
				characterEditor = selectedEntity.gameObject.AddComponent<CharacterEditor>();
			}
			this.handleManager.SetTarget(characterEditor);
			this.EnableTabs();
		}

		// Token: 0x06000C5F RID: 3167 RVA: 0x00064C14 File Offset: 0x00062E14
		protected override void OnSelection()
		{
			if (this.Controller == null || this.Controller.selectedEntity == null)
			{
				base.gameObject.SetActive(false);
				return;
			}
			CharacterEditor component = this.Controller.selectedEntity.GetComponent<CharacterEditor>();
			if (!component)
			{
				this.DisableTabs();
			}
			else
			{
				this.EnableCharacterEditor();
			}
		}

		// Token: 0x04001184 RID: 4484
		[SerializeField]
		[Header("View References")]
		[Space(15f)]
		private BaseView startView;

		// Token: 0x04001185 RID: 4485
		[SerializeField]
		private BaseView bodyView;

		// Token: 0x04001186 RID: 4486
		[SerializeField]
		private HandleManager handleManager;
	}
}
